<?php
// +----------------------------------------------------------------------
// | Author: yaoyihong <510974211@qq.com>
// +----------------------------------------------------------------------

namespace addon\cms\model;
use \think\Request;
use app\common\model\AddonBase;
use tpfcore\helpers\StringHelper;
class Posts extends AddonBase
{
    protected $auto = ['updatetime','uid','abstract'];

    protected function setUpdatetimeAttr()
    {
        return time();
    }
    protected function setDatetimeAttr($value)
    {
        return strtotime($value);
    }
    protected function setUidAttr()
    {
        return session("backend_author_sign")['userid'];
    }
    protected function setIscheckAttr(){
        if(config("config.POSTS_CHECK_WAY")==1){
            return 1;
        }else{
            return 0;
        }
    }
    protected function setAbstractAttr($value){
        $content = input("content");
        if(empty($value)){
            return StringHelper::msubstr($content,0,config("config.cut_posts_length"));
        }else{
            return $value;
        }
    }
}
